package org.apache.commons.httpclient;

import java.io.IOException;
import org.apache.commons.httpclient.params.HttpMethodParams;
import org.apache.commons.httpclient.protocol.Protocol;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

public class ConnectMethod extends HttpMethodBase
{
  private static final Log LOG;
  public static final String NAME = "CONNECT";
  static Class class$org$apache$commons$httpclient$ConnectMethod;
  private final HostConfiguration targethost;

  static
  {
    Class localClass;
    if (class$org$apache$commons$httpclient$ConnectMethod == null)
    {
      localClass = class$("org.apache.commons.httpclient.ConnectMethod");
      class$org$apache$commons$httpclient$ConnectMethod = localClass;
    }
    while (true)
    {
      LOG = LogFactory.getLog(localClass);
      return;
      localClass = class$org$apache$commons$httpclient$ConnectMethod;
    }
  }

  public ConnectMethod()
  {
    this.targethost = null;
  }

  public ConnectMethod(HostConfiguration paramHostConfiguration)
  {
    if (paramHostConfiguration == null)
      throw new IllegalArgumentException("Target host may not be null");
    this.targethost = paramHostConfiguration;
  }

  public ConnectMethod(HttpMethod paramHttpMethod)
  {
    this.targethost = null;
  }

  static Class class$(String paramString)
  {
    try
    {
      Class localClass = Class.forName(paramString);
      return localClass;
    }
    catch (ClassNotFoundException localClassNotFoundException)
    {
      throw new NoClassDefFoundError(localClassNotFoundException.getMessage());
    }
  }

  protected void addCookieRequestHeader(HttpState paramHttpState, HttpConnection paramHttpConnection)
    throws IOException, HttpException
  {
  }

  protected void addRequestHeaders(HttpState paramHttpState, HttpConnection paramHttpConnection)
    throws IOException, HttpException
  {
    LOG.trace("enter ConnectMethod.addRequestHeaders(HttpState, HttpConnection)");
    addUserAgentRequestHeader(paramHttpState, paramHttpConnection);
    addHostRequestHeader(paramHttpState, paramHttpConnection);
    addProxyConnectionHeader(paramHttpState, paramHttpConnection);
  }

  public int execute(HttpState paramHttpState, HttpConnection paramHttpConnection)
    throws IOException, HttpException
  {
    LOG.trace("enter ConnectMethod.execute(HttpState, HttpConnection)");
    int i = super.execute(paramHttpState, paramHttpConnection);
    if (LOG.isDebugEnabled())
      LOG.debug("CONNECT status code " + i);
    return i;
  }

  public String getName()
  {
    return "CONNECT";
  }

  public String getPath()
  {
    StringBuffer localStringBuffer;
    if (this.targethost != null)
    {
      localStringBuffer = new StringBuffer();
      localStringBuffer.append(this.targethost.getHost());
      int i = this.targethost.getPort();
      if (i == -1)
        i = this.targethost.getProtocol().getDefaultPort();
      localStringBuffer.append(':');
      localStringBuffer.append(i);
    }
    for (String str = localStringBuffer.toString(); ; str = "/")
      return str;
  }

  public URI getURI()
    throws URIException
  {
    String str = getParams().getUriCharset();
    return new URI(getPath(), true, str);
  }

  protected boolean shouldCloseConnection(HttpConnection paramHttpConnection)
  {
    if (getStatusCode() == 200)
    {
      Header localHeader = null;
      if (!(paramHttpConnection.isTransparent()))
        localHeader = getResponseHeader("proxy-connection");
      if (localHeader == null)
        localHeader = getResponseHeader("connection");
      if ((localHeader != null) && (localHeader.getValue().equalsIgnoreCase("close")) && (LOG.isWarnEnabled()))
        LOG.warn("Invalid header encountered '" + localHeader.toExternalForm() + "' in response " + getStatusLine().toString());
    }
    for (boolean bool = false; ; bool = super.shouldCloseConnection(paramHttpConnection))
      return bool;
  }

  protected void writeRequestLine(HttpState paramHttpState, HttpConnection paramHttpConnection)
    throws IOException, HttpException
  {
    StringBuffer localStringBuffer = new StringBuffer();
    localStringBuffer.append(getName());
    localStringBuffer.append(' ');
    if (this.targethost != null)
      localStringBuffer.append(getPath());
    while (true)
    {
      localStringBuffer.append(" ");
      localStringBuffer.append(getEffectiveVersion());
      String str = localStringBuffer.toString();
      paramHttpConnection.printLine(str, getParams().getHttpElementCharset());
      if (Wire.HEADER_WIRE.enabled())
        Wire.HEADER_WIRE.output(str);
      return;
      int i = paramHttpConnection.getPort();
      if (i == -1)
        i = paramHttpConnection.getProtocol().getDefaultPort();
      localStringBuffer.append(paramHttpConnection.getHost());
      localStringBuffer.append(':');
      localStringBuffer.append(i);
    }
  }
}

/* Location:           E:\Desktop\Android\wordstd\classes_dex2jar.jar
 * Qualified Name:     org.apache.commons.httpclient.ConnectMethod
 * JD-Core Version:    0.5.3
 */